<?php 
	jimport('joomla.application.component.model');
	class kinh_doanhModelsp_trong_kho_lon extends JModel
	{
        //danh sach sp trong kho
        function ds_sp_kho_lon()
        {
            if(isset($_REQUEST['id']))
            {
                $id=$_REQUEST['id'];
                $_SESSION['id_kho'] = $id;
            }
            $db = &JFactory::getDBO();
            $sql = "SELECT  pr.name, sum(wp.number_of) as sum, wp.id_warehouse as id_kho, pr.id as id_pro
                FROM  #__erp_warehouse_ex_pro wp,  #__erp_product pr
                WHERE wp.id_warehouse = '".$_SESSION['id_kho']."'
                AND pr.id = wp.id_product
                GROUP BY wp.id_product
                ";
            $db->setQuery($sql);
            return $db->loadObjectList();
        }
	}
?>